<?php if (!defined('THINK_PATH')) exit();?><!--这是Node首页-->

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>节点列表</title>
<!--引入样式 -->
<link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/Js/jquery-2.1.3.js"></script>

<!--引入样JS-->
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

<script type="text/javascript">
  $(function(){
     $("input[level=1]").click(function(){
    	 var inputs=$(this).parents("dt").find("input");
         $(this).attr("checked")? inputs.attr("checked","checked"): inputs.removeAttr("checked");
     });
     
     $("input[level=2]").click(function(){
    	 var inputs=$(this).parents("dd").find("input");
         $(this).attr("checked")? inputs.attr("checked","checked"): inputs.removeAttr("checked");
         
         if(!$(this).attr("checked")){
        	 var flag=false;
        	
        	$(this).parents("dd").siblings().children("input:eq(0)").each(function(i,e){
        	
        		if($(this).attr("checked")){        					
        			flag=1;       			
        			return;
        		}
        		
        	})
        	
        	if(!flag){
        		$(this).parents("dt").children("input:eq(0)").attr("checked",false);
        	}
         }else{
        	 $(this).parents("dt").children("input:eq(0)").attr("checked","checked");
         }
     });
     
     //li节点点击
     $("li input").click(function(){
    	if($(this).attr('checked')){
    		$(this).parents("dd").children("input:eq(0)").attr('checked','checked');
    		$(this).parents("dt").children("input:eq(0)").attr('checked','checked');
    	}else{
    		var parent=$(this).parents("ul").find("input");
    		var flag=false;
    		
    		parent.each(function(i,v){
    			if(this.checked){
    				flag=1;
    				return;	
    			}		
    		})
    	
    		if(flag){	
    			$(this).parents("dd").children("input:eq(0)").attr('checked','checked');
    			$(this).parents("dt").children("input:eq(0)").attr('checked','checked');
    		}else{
    			$(this).parents("dd").children("input:eq(0)").attr('checked',false);
    			
    			var flag2=false;
    			
    			$(this).parents("dd:eq(0)").siblings().children("input:eq(0)").each(function(i,v){
    				if(this.checked){
    					flag2=1;
    					
    				}
    			})
    			
    			if(!flag2){
    				
    				$(this).parents("dt").children("input:eq(0)").attr("checked",false);
    			}
    		}
    	}
     });
     
     
    
  })
</script>


<style type="text/css">
    /* Custom Styles */
    ul.nav-tabs{
        width: 140px;
        margin-top: 20px;
        border-radius: 4px;
        border: 1px solid #ddd;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
    }
    ul.nav-tabs li{
        margin: 0;
        border-top: 1px solid #ddd;
    }
    ul.nav-tabs li:first-child{
        border-top: none;
    }
    ul.nav-tabs li a{
        margin: 0;
        padding: 8px 16px;
        border-radius: 0;
    }
    ul.nav-tabs li.active a, ul.nav-tabs li.active a:hover{
        color: #fff;
        background: #0088cc;
        border: 1px solid #0088cc;
    }
    ul.nav-tabs li:first-child a{
        border-radius: 4px 4px 0 0;
    }
    ul.nav-tabs li:last-child a{
        border-radius: 0 0 4px 4px;
    }
    ul.nav-tabs.affix{
        top: 30px; /* Set the top position of pinned element */
    }
    .img{
	width:80px;
    height:25px;
    	
    }
ul li{
margin:0px;
padding:0px;
list-style-type:none;
}
.header{
border:1px #0099FF solid;
}
.bd{
border:1px  #993333 solid;
overflow:hidden;
width:100%;
padding:2px;

}
.bd .left{
 float:left;

}
.bd .right{
 float:left;

}
.left{
border:1px #0099FF solid;
width:20%;
height:auto;
}

.right{
border:1px #0099FF solid;
width:80%;
height:auto;
}

.mylist{
   width:80%;
   height:200px;
   border:1px black solid;
   margin:10px auto;

  }
.mylist ul{
  margin:10px auto;
  border:1px #993399 solid;
  width:80%;
}
  .mylist ul li{
  border:1px yellow solid;
    
  text-align:center;
  width:100%;
  height:auto; 	
  margin:0 auto;
  margin-left:-18px;	
  }
 .contain li{
	float:left;	
 	padding:0px 10px;	
 }
 .contain dl{
	padding:0px 10px;
 }
.contain dl dt{
	margin:10px 0px;
}
 
</style>
</head>
<body>

<div class="contain">
<strong><a href='<?php echo U("Admin/Rbac/Role");?>'>返回</a></strong>
   <div class='app'>
	 <form action="<?php echo U('Admin/Rbac/SetAccess');?>"  method="post" >
	     <dl class="level0">
	        <?php if(is_array($node)): foreach($node as $key=>$app): ?><dt>
	           <strong><?php echo ($app["name"]); ?></strong> 
	           <input type='checkbox' name='access[]' value="<?php echo ($app['id']); ?>_<?php echo ($app['level']); ?>" level="<?php echo ($app['level']); ?>" 
	             <?php if($app["access"]): ?>checked='checked'<?php endif; ?>/>
	           
		           <dl  class="level1"> 
			           <?php if(is_array($app["child"])): foreach($app["child"] as $key=>$action): ?><dd><?php echo ($action["name"]); ?>  
			                 <input type='checkbox' name='access[]' value="<?php echo ($action['id']); ?>_<?php echo ($action['level']); ?>" level="<?php echo ($action['level']); ?>"
			                 <?php if($action["access"]): ?>checked='checked'<?php endif; ?>/> 
			                 
			                 <ul  class="level2">
				                 <?php if(is_array($action["child"])): foreach($action["child"] as $key=>$method): ?><li><?php echo ($method["title"]); ?>
				                      <input type='checkbox' name='access[]' value="<?php echo ($method['id']); ?>_<?php echo ($method['level']); ?>" level="<?php echo ($method['level']); ?>"
				                      <?php if($method["access"]): ?>checked='checked'<?php endif; ?>/>
				                    </li><?php endforeach; endif; ?>
			                 </ul><br/>
			                </dd><?php endforeach; endif; ?>
		           </dl>
	          </dt></br><?php endforeach; endif; ?>
	    </dl>
	    <input name="rid" value="<?php echo ($rid); ?>" type="hidden"/>
	    <input type="submit" value="保存提交"/>
	 </form>
   </div>
</div>
</body>
</html>